home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
GRAPHICS
/
TS32
/
COLORPAL.INT
< prev
next >
Wrap
Text File
|
1996-03-21
|
3KB
|
107 lines
(***************************************************
TColorPalette->TComponent
Manages a 256 color logical palette.
Properties
BadEntries-
If this palette is not an identity palette, this StringList
will contain the palette entries that are responsible and
require alteration.
IdentityPalette-
Indicates whether this palette qualifies as an identity palette.
ImagePalette-
Assigning this property to a TImage on the form causes the
palette of the TImage to be copied into the TColorPalette.
The reference to the TImage is not maintained, but the physical
palette data is.
PalEntryFlag-
Indicates if the palette entries should be flagged as PC_NOCOLLAPSE
or PC_RESERVED. The recommended setting is PC_NOCOLLPASE.
Palette-
The HPalette handle that corresponds to the logical palette.
PaletteEntry[n]-
Accesses the palette entry structure at the specified index.
When modifying palette entries, call the Refresh method
to regenerate the palette.
PaletteEntries-
In design mode brings up a property editor that allows you
to manipulate the palette visually.
Events
Methods
Refresh-
Causes the logical palette to regenerate. Call this after changing
PaletteEntry values.
***************************************************)
unit ColorPalette;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, Utility, DsgnIntf;
type
EPalette = class( Exception );
TPAL = record
logPalette: TLogPalette;
palpalEntry: array[0..255] of TPaletteEntry;
end;
TPalEntryFlag = ( pcNoCollapse, pcReserved );
TColorPalette = class( TComponent )
private
bEntries: boolean;
FEntries: TStrings;
FFlag: TPalEntryFlag;
FFlag_: byte;
FPalette: HPALETTE;
pal: TPAL;
FImage: TImage;
bDummy: boolean;
nDummy: integer;
FBadEntries: TStrings;
procedure PaletteEntriesToStrings;
procedure SetPaletteHandle( bStoreStrings: boolean );
protected
procedure Loaded; override;
procedure SetFlag( f: TPalEntryFlag );
procedure SetImage( im: TImage );
procedure SetEntries( str: TStrings );
function IsIdentityPalette: boolean;
procedure SetBadEntry( str: TStrings );
function GetPaletteEntry( n: byte ): TPaletteEntry;
procedure SetPaletteEntry( n: byte; pal: TPaletteEntry );
public
constructor Create( AOwner: TComponent ); override;
destructor Destroy; override;
procedure Assign( Source: TPersistent ); override;
procedure Refresh;
property Palette: HPALETTE read FPalette write FPalette;
property PaletteEntry[n: byte]: TPaletteEntry read GetPaletteEntry write SetPaletteEntry;
published
property BadEntries: TStrings read FBadEntries write SetBadEntry;
property PaletteEntries: TStrings read FEntries write SetEntries;
property ImagePalette: TImage read FImage write SetImage;
property IdentityPalette: boolean read IsIdentityPalette write bDummy;
property PalEntryFlag: TPalEntryFlag read FFlag write SetFlag default pcNoCollapse;
end;
TColorPaletteEditor = class( TPropertyEditor )
private
protected
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
procedure Register;